
<template>
	<!-- 添加弹框 -->
	<el-dialog title="学生销售添加管理" :visible.sync="dialogTableVisible" class="wrap" @close="cancel" :close-on-click-modal="false">
		<div class="input-block">
			<span>学生id：</span>
			<el-input v-model="vxsid" placeholder="请输入学生id" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>物品名称：</span>
			<el-input v-model="vwpid"  placeholder="请选择物品名称" icon="add" class="input" v-if="false" ></el-input>
			<el-input v-model="vwpidmc" placeholder="请选择物品名称" icon="add" class="input1" :readonly="true"></el-input>
			<el-button  @click="showwp()" >选择</el-button>
		</div>
		<div class="input-block">
			<span>销售数量：</span>
			<el-input v-model="vxssl" placeholder="请输入销售数量" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>折扣：</span>
			<el-input v-model="vzk" placeholder="请输入折扣" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>实际收款：</span>
			<el-input v-model="vsjsk" placeholder="请输入实际收款" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>备注：</span>
			<el-input v-model="vbz" type="textarea"  :rows="4"  placeholder="请输入备注" icon="add" class="input2"></el-input>
		</div>
		<el-button type="info" class="submit" @click="submit">保存</el-button>
		
		<Wpchooselist class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"  ></Wpchooselist>
	</el-dialog>
</template>
<script type="text/javascript">
	import Wpchooselist from '../wpfx/wpchooselist'
	import qs from 'qs'
	export default {
		components: { Wpchooselist},
		data() {
			return {
				showchoselist:false,
				vxsid: '',
				vwpid: '',
				vwpidmc:'',
				vxssl: '',
				vzk: '',
				vsjsk: '',
				vbz: '',
				dialogTableVisible: true
			}
		},
		methods: {
			submit() {
				//检测
				this.$store.state.loading = true;
			    if(!this.vxsid) {
					this.$message.warning('请选择物品名称');
					this.$store.state.loading = false;
					return;
				} 
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
    			xsid: this.vxsid,
    			wpid: this.vwpid,
    			xssl: this.vxssl,
    			zk: this.vzk,
    			sjsk: this.vsjsk,
    			bz: this.vbz,
				yhid: logininfo.id,
				xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xsxs/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			showwp(){
				this.showchoselist =true;
			},
			wpchooseed(josndata){
				this.vwpidmc = josndata.wpmc;
				this.vwpid=josndata.wpid; 
						this.showchoselist=false;
			},
			wpchoosecancel(){
						this.showchoselist=false; 
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width: 300px;
			display: inline-block;
		}
		.input1 {
			width: 240px;
			display: inline-block;
		}
		.input2 {
			width: 300px;
			display: inline-block;
			vertical-align: middle;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
		.wpfl{
			background: #fff;
			position: absolute;
			top: 5px;
			left: -91px;
			height: 98%;
		}
	}
</style>
